<template>
  <div>
    <el-container>

      <el-main>
        <el-container class="parent-body">
          <el-header class="content-header">
            <div>商品类目销售分析</div>
            <div>
              <el-button @click="exportOrder">导出数据</el-button>
              <el-button-group class="margin-left">
                <el-button type="primary" @click="exportOrder">最近7天</el-button>
                <el-button @click="exportOrder">最近30天</el-button>
                <el-button @click="exportOrder">最近90天</el-button>
              </el-button-group>
              <el-date-picker class="margin-left"
                      v-model="value1"
                      type="datetimerange"
                      start-placeholder="开始日期"
                      end-placeholder="结束日期"
                      :default-time="['12:00:00']">
              </el-date-picker>
            </div>
          </el-header>
          <el-main class="info-main padding-style">
            <div id="orderSC" style="width:900px;height: 400px;margin: 10px auto;"></div>

            <el-table :data="tableData" height="100%" border style="width: 100%">
              <el-table-column prop="number" label="分类名称" width="150"></el-table-column>
              <el-table-column prop="name" sortable label="销售数量"> </el-table-column>
              <el-table-column prop="money" label="数量比例"> </el-table-column>
              <el-table-column prop="stater" label="销售金额"> </el-table-column>
              <el-table-column prop="note" label="金额比例"> </el-table-column>
            </el-table>
          </el-main>
        </el-container>
      </el-main>
      <el-footer>
        <el-container class="parent-body">
          <el-header class="content-header">
            <div>商品销售情况</div>
            <div>
              <el-button @click="exportOrder">导出数据</el-button>
              <el-button-group class="margin-left">
                <el-button type="primary" @click="exportOrder">最近7天</el-button>
                <el-button @click="exportOrder">最近30天</el-button>
                <el-button @click="exportOrder">最近90天</el-button>
              </el-button-group>
              <el-date-picker class="margin-left"
                              v-model="value2"
                              type="datetimerange"
                              start-placeholder="开始日期"
                              end-placeholder="结束日期"
                              :default-time="['12:00:00']">
              </el-date-picker>
            </div>
          </el-header>
          <el-main class="info-main padding-style">
            <el-table :data="tableData02" height="100%" border style="width: 100%">
              <el-table-column prop="number" label="商品名称" width="150"></el-table-column>
              <el-table-column prop="datetime" sortable label="浏览量" width="160"></el-table-column>
              <el-table-column prop="name" label="浏览人数"> </el-table-column>
              <el-table-column prop="money" label="付款人数"> </el-table-column>
              <el-table-column prop="methodPayment" label="单品转化率"> </el-table-column>
              <el-table-column prop="source" label="销售数量"> </el-table-column>
              <el-table-column prop="stater" label="销售金额"> </el-table-column>
            </el-table>
          </el-main>
          <el-footer class="info-foot">
            <div class="paging-style">
              <el-pagination
                      background
                      @size-change="handleSizeChange"
                      @current-change="handleCurrentChange"
                      :current-page.sync="currentPage1"
                      :page-size="pageSize"
                      layout="total, prev, pager, next, jumper"
                      :total="total">
              </el-pagination>
            </div>
          </el-footer>
        </el-container>
      </el-footer>
    </el-container>

  </div>
</template>

<script>
    export default {
        data() {
            return {
                value1: '',
                value2:'',
                pageSize:10,
                total:2,
                currentPage1:1,
                showData:[
                    ['product', '2012', '2013'],
                    ['彩妆', 41.1,92.1],
                    ['留学', 86.5, 92.1],
                    ['派遣', 24.1, 67.2],
                    ['法律服务', 55.2, 67.1],
                    ['厨具', 55.2, 10.1],
                    ['男装', 55.2, 67.1],
                    ['家电', 55.2, 67.1],
                    ['食品', 55.2, 67.1]
                ],
                tableData02: [{
                    number: '2018 iphoneXsMax128GB',
                    datetime:1,
                    name: '1000',
                    money: '100',
                    methodPayment: '10%',
                    source: '100',
                    stater: '￥10000.00'
                },{
                    number: '2018 iphoneXsMax128GB',
                    datetime:2,
                    name: '1000',
                    money: '100',
                    methodPayment: '10%',
                    source: '100',
                    stater: '￥10000.00'
                },{
                    number: '2018 iphoneXsMax128GB',
                    datetime:1000,
                    name: '1000',
                    money: '100',
                    methodPayment: '10%',
                    source: '100',
                    stater: '￥10000.00'
                },{
                    number: '2018 iphoneXsMax128GB',
                    datetime:1000,
                    name: '1000',
                    money: '100',
                    methodPayment: '10%',
                    source: '100',
                    stater: '￥10000.00'
                },],
                tableData: [{
                    number: '彩妆',
                    name: 4,
                    money: '20%',
                    stater: '￥10000.00',
                    note:'20%'
                },{
                    number: '食品',
                    name: 100,
                    money: '20%',
                    stater: '￥10000.00',
                    note:'20%'
                },{
                    number: '家电',
                    name: 1,
                    money: '20%',
                    stater: '￥10000.00',
                    note:'20%'
                },{
                    number: '厨具',
                    name: 100,
                    money: '20%',
                    stater: '￥10000.00',
                    note:'20%'
                },]
            }
        },
        methods:{
            exportOrder(){

            },
            handleSizeChange(val) {
                alert(`每页 ${val} 条`);
            },
            handleCurrentChange(val) {
                alert(`当前页: ${val}`);
            },
            OrderChart() {
                // 基于准备好的dom，初始化echarts实例
                let myChart = this.$echarts.init(document.getElementById("orderSC"))
                // 指定图表的配置项和数据
                var option = {
                    title: {
                        text: "一级分类商品",
                        left: 'center'
                    },
                    legend: {
                        bottom: 'bottom',
                    },
                    tooltip: {},
                    dataset: {
                        source: this.showData
                    },
                    series: [{
                        type: 'pie',
                        radius: '55%',
                        center: ['25%', '50%']
                    }
                        ,{
                        type: 'pie',
                        radius: '55%',
                        center: ['75%', '50%'],
                        encode: {
                            itemName: 'product',
                            value: '2013'
                        }
                    }
                    ]
                };
                // 使用刚指定的配置项和数据显示图表。
                myChart.setOption(option)
            },
        },
        mounted() {
            this.OrderChart()
        }
    }
</script>

<style scoped>
  .badges {
    height: 60px;
    padding: 10px;
  }
  .common-home,.content-header{
    border-bottom:1px solid #E4E4E4;
    position: relative;
  }
  .common-home>div{
    display: inline-block;
    width:100px;
    height:50px;
    vertical-align: top;
    text-align: center;
    line-height: 50px;
    color:#666666;
  }
  .common-home>.refresh{
    position: absolute;
    right:10px;
  }
  .common-home>div>span{
    border:4px solid #0399FE;
    display: inline-block;
    width: 0px;
    height: 15px;
    vertical-align: middle;
    margin-right: 5px;
    background-color: #0399FE;
  }
  .parent-body{
    border:1px solid #E4E4E4;
  }
  .content-header{
    height:50px;
    line-height: 50px;
    background-color:#F3F3F3;
    color:#666666;
    position: relative;
    text-align: left;
  }
  .info-main{
    background-color:#fff;
  }

  .content-header>div{
    display: inline-block;
  }
  .content-header>div:last-of-type{
    position: absolute;
    right:10px;
  }
  .input-width{
    width:200px;
  }
  .select-div{
    display: inline-block;
    width:300px;
  }
  .input-width2{
    width:120px;
  }
  .input-width3{
    width:400px;
  }
  .padding-style{
    padding:0 !important;
  }

  .info-foot{
    background-color:#FDFDFE;
    height:60px;
    line-height: 60px;
    position: relative;
  }
  .paging-style{
    position: absolute;
    right:10px;
    display: inline-block;
    top:15px;
  }
  .margin-left{
    margin-left:10px;
  }
  .search-style{
    width:50%;
    display: inline-block;
    vertical-align: top;
  }
</style>

